and fix a bug revealed by the warning.
const dg100_command* dg100_findcmd(int id) const;
static QDateTime bintime2utc(int date, int time);
static void dg100_debug(const char* hdr, int include_nl, size_t sz, unsigned char* buf);
- static void dg100_log(const char* fmt, ...);
+ [[gnu::format(printf, 1, 2)]] static void dg100_log(const char* fmt, ...);
static float bin2deg(int val);
void process_gpsfile(uint8_t* data, route_head** track) const;
static uint16_t dg100_checksum(const uint8_t* buf, int count);
#define MYMAGIC 0x91827364
#define BUFSIZE 512
-void gbser_db(int l, const char* msg, ...);
+[[gnu::format(printf, 2, 3)]] void gbser_db(int l, const char* msg, ...);
int gbser_fill_buffer(void* handle, unsigned want, unsigned* ms);
unsigned gbser_read_buffer(void* handle, void** buf, unsigned* len);
#endif // GBSER_PRIVATE_H_
/* Member Functions */
- void gtc_write_xml(int indent, const char* fmt, ...);
+ [[gnu::format(printf, 3, 4)]] void gtc_write_xml(int indent, const char* fmt, ...);
void gtc_write_xml(int indent, const QString& s);
void gtc_lap_start(const route_head* /* unused */);
static computed_trkdata gtc_new_study_lap(const route_head* rte);
{
int32 i;
US v;
- char s[GPS_ARB_LEN];
i=0;
while ((v=GPS_MP[i].id)) {
}
- (void) snprintf(s, sizeof(s), "INIT: No table entry for ID %d\n", id);
- GPS_Error(s);
+ GPS_Error("INIT: No table entry for ID %d\n", id);
return GPS_UNSUPPORTED;
}
void GPS_Protocol_Error(US tag, US data)
{
- char s[GPS_ARB_LEN];
-
- (void) snprintf(s, sizeof(s),
- "PROTOCOL ERROR: Unknown tag/data [%c/%d]\n", tag, data);
- GPS_Error(s);
+ GPS_Error("PROTOCOL ERROR: Unknown tag/data [%c/%d]\n", tag, data);
if (gps_n_tag_unknown < GPS_TAGUNK) {
gps_tag_unknown[gps_n_tag_unknown] = tag;
/*
* Display an error from the serial subsystem.
*/
-void GPS_Serial_Error(const char* mb, ...)
+void GPS_Serial_Error(const char* fmt, ...)
{
va_list ap;
char msg[200];
char* s;
int b;
- va_start(ap, mb);
- b = vsnprintf(msg, sizeof(msg), mb, ap);
+ va_start(ap, fmt);
+ b = vsnprintf(msg, sizeof(msg), fmt, ap);
s = msg + b;
*s++ = ':';
*s++ = ' ';
- FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0,
- GetLastError(), 0, s, sizeof(msg) - b - 2, 0);
- GPS_Error(msg);
+ FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr,
+ GetLastError(), 0, s, sizeof(msg) - b - 2, nullptr);
+
+ GPS_Error("%s", msg); // valid clang -Wformat-security warning
va_end(ap);
}
/*
* Display an error from the serial subsystem.
*/
-void GPS_Serial_Error(const char* mb, ...)
+void GPS_Serial_Error(const char* fmt, ...)
{
va_list ap;
char msg[200];
- char* s;
- int b;
- va_start(ap, mb);
- b = vsnprintf(msg, sizeof(msg), mb, ap);
- s = msg + b;
- *s++ = ':';
- *s++ = ' ';
- *s++ = '\0';
+ va_start(ap, fmt);
+ vsnprintf(msg, sizeof(msg), fmt, ap);
// FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, 0,
// GetLastError(), 0, s, sizeof(msg) - b - 2, 0 );
- strcat(msg, strerror(errno));
- GPS_Error(msg);
+ GPS_Error("%s: %s", msg, strerror(errno));
va_end(ap);
}
uint32 GPS_Util_Get_Uint(const UC* s);
void GPS_Warning(const char* s);
- void GPS_Error(const char* fmt, ...);
- void GPS_Serial_Error(const char* hdr, ...);
+ [[gnu::format(printf, 1, 2)]] void GPS_Error(const char* fmt, ...);
+ [[gnu::format(printf, 1, 2)]] void GPS_Serial_Error(const char* fmt, ...);
void GPS_Fatal(const char* s);
void GPS_Enable_Error();
void GPS_Enable_Warning();
void GPS_Disable_Error();
void GPS_Disable_Warning();
- void GPS_User(const char* fmt, ...);
+ [[gnu::format(printf, 1, 2)]] void GPS_User(const char* fmt, ...);
void GPS_Disable_User();
void GPS_Enable_User();
void GPS_Diagnose(int32 c);
- void GPS_Diag(const char* fmt, ...);
+ [[gnu::format(printf, 1, 2)]] void GPS_Diag(const char* fmt, ...);
void GPS_Enable_Diagnose();
void GPS_Disable_Diagnose();
},
};
-static void dbg(int l, const char* msg, ...)
+[[gnu::format(printf, 2, 3)]] static void dbg(int l, const char* msg, ...)
{
va_list ap;
va_start(ap, msg);
/* Member Functions */
- static void db(int l, const char* msg, ...);
+ [[gnu::format(printf, 2, 3)]] static void db(int l, const char* msg, ...);
void rd_drain() const;
int rd_char(int* errors) const;
int rd_buf(uint8_t* buf, int len) const;
static FILE* fin = nullptr;
/* copied from dg-100.cpp */
-static void
+[[gnu::format(printf, 1, 2)]] static void
v900_log(const char* fmt, ...)
{
va_list ap;
struct buf_head data;
};
-static void db(int l, const char* msg, ...)
+[[gnu::format(printf, 2, 3)]] static void db(int l, const char* msg, ...)
{
va_list ap;
va_start(ap, msg);
}
if (cs != st->data.checksum) {
- db(2, "Checksums don't match. Got %02lx, expected %02\n", cs, st->data.checksum);
+ db(2, "Checksums don't match. Got %02lx, expected %02x\n", cs, st->data.checksum);
return 0;
}